package rd.hardcore.ui.pad.stream 
{
	import aze.motion.eaze;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.ColorMatrixFilter;
	import flash.geom.Rectangle;
	import flash.utils.setTimeout;
	import rd.hardcore.datas.Track;
	import rd.hardcore.engine.datas.StreamBoardManager;
	import rd.hardcore.events.OutDragInEvent;
	import rd.hardcore.events.SoundSystemEvent;
	import rd.hardcore.ui.pad.Pad;
	
	/**
	 * ...
	 * @author Romain Prache
	 */
	public class StreamPad extends Pad
	{
		
		public function StreamPad() 
		{
			super();

			front.streamable = true;
			
			front.removeEventListener(OutDragInEvent.DRAG_OVER, drag_overHandler);
			front.removeEventListener(OutDragInEvent.DRAG_OUT, drag_outHandler);
			front.removeEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);
		}
		
		override public function build(_node:XML):void 
		{
			//super.build(_node);			
			keyId 	= int(	_node.@keyId.toString() );
			key		= int(	_node.toString()		);
			pos		= int(	_node.@pos.toString()	);
			hit		= int(	_node.@hit.toString()	);
			
			_track = StreamBoardManager.instance.getTrackById(keyId);		
			front.setThumb(track.thumb);
			front.track = _track;
		}
		
		override public function registerSound():void 
		{	
			if (! track.file || track.file == "medias/songs/empty.mp3") return;
			
			dispatchEvent(	new SoundSystemEvent(SoundSystemEvent.PLAY_SOUND, track, true )	);
			track.cpt++;

			eaze(front).from(.3).filter(ColorMatrixFilter, { brightness: .5 } );
			
			setTimeout(cleanRoll, 400);
		}


	}

}